var http = require('../../utils/http')
Page({

    /**
     * 页面的初始数据
     */
    data: {
        myFriendList: [],
        self: {},
        record: {
            userId: 1,
            userName: '张三',
            userAvatar: '11111111111',
            text: 'sadfjsdjsd',
            time: '2023.1.1 02:22:30',
            friendId: 5,
            records:[]
        },
        username: '哈哈'
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            self: wx.getStorageSync('userInfo'),
        })
        this.findmyFriend();
    },

    findmyFriend() {
        const id = this.data.self.id
        const that = this;
        http.get(`/mini/findMyFriend/${id}`,{},res=>{
            that.setData({
                myFriendList:res.data.data
            })
        })
    },

    addRecord() {
        const that = this;
        http.post("/mini/addRecord",that.data.record,res=>{
            console.log(res);
        })
    },

    toContacts() {
        wx.navigateTo({
            url: `/pages/message/contact/contact`
        })
    },
    toRecords(e) {
        const item = e.target.dataset.item;
        wx.navigateTo({
            url: `/pages/message/records/records?item=` + encodeURIComponent(JSON.stringify(item)),
        })
    },
    onShow: function () {
        this.getTabBar().init();
	},

})